package com.jkj.webservice;

import com.jkj.webservice.service.SystemService;
import com.jkj.webservice.serviceimp.SystemServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {


//    @Bean
//    public ServletRegistrationBean dispatcherServlet() {
//        return new ServletRegistrationBean(new CXFServlet(), "/service/*");//发布服务名称
//    }

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }


    @Bean
    public SystemService systemService() {
        return new SystemServiceImpl();
    }

    @Bean
    public Endpoint systemEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), systemService());//绑定要发布的服务
        endpoint.publish("/system"); //显示要发布的名称
        //http://127.0.0.1:8080/service/system?wsdl
        return endpoint;
    }

}